avoid showing warnings for excluded files to not confuse users
authorMatthieu Gallien <matthieu.gallien@nextcloud.com>
Thu, 6 Mar 2025 15:24:13 +0000 (16:24 +0100)
committerMatthieu Gallien <matthieu.gallien@nextcloud.com>
Wed, 12 Mar 2025 14:12:50 +0000 (15:12 +0100)
if a file name is invalid, the files will be ignored

if a file is excluded because of selective sync, the file will be
ignored

if a file is ignored for those both reasons, avoid showing a very
visible warning to the user

will limit too many warnings and notifications being shown

Signed-off-by: Matthieu Gallien <matthieu.gallien@nextcloud.com>
src/libsync/discovery.cpp
src/libsync/discovery.h

index 2e4fa09da54ed36f1b398ab777e1a61fe9e9386d..ce8ef8d306e0f3d81ff0634c9d5fb549c28b541d 100644 (file)
@@ -245,12 +245,16 @@ void ProcessDirectoryJob::process()
             checkAndUpdateSelectiveSyncListsForE2eeFolders(path._server + "/");
         }
 
-        if (_queryServer == InBlackList || _discoveryData->isInSelectiveSyncBlackList(path._original) || isEncryptedFolderButE2eIsNotSetup) {
-            processBlacklisted(path, e.localEntry, e.dbEntry);
+        const auto isBlacklisted = _queryServer == InBlackList || _discoveryData->isInSelectiveSyncBlackList(path._original) || isEncryptedFolderButE2eIsNotSetup;
+
+        const auto willBeExcluded = handleExcluded(path._target, e, entries, isHidden, isBlacklisted);
+
+        if (willBeExcluded) {
             continue;
         }
 
-        if (handleExcluded(path._target, e, entries, isHidden)) {
+        if (isBlacklisted) {
+            processBlacklisted(path, e.localEntry, e.dbEntry);
             continue;
         }
 
@@ -266,7 +270,7 @@ void ProcessDirectoryJob::process()
     QTimer::singleShot(0, _discoveryData, &DiscoveryPhase::scheduleMoreJobs);
 }
 
-bool ProcessDirectoryJob::handleExcluded(const QString &path, const Entries &entries, const std::map<QString, Entries> &allEntries, bool isHidden)
+bool ProcessDirectoryJob::handleExcluded(const QString &path, const Entries &entries, const std::map<QString, Entries> &allEntries, const bool isHidden, const bool isBlacklisted)
 {
     const auto isDirectory = entries.localEntry.isDirectory || entries.serverEntry.isDirectory;
 
@@ -497,7 +501,13 @@ bool ProcessDirectoryJob::handleExcluded(const QString &path, const Entries &ent
     }
 
     _childIgnored = true;
-    emit _discoveryData->itemDiscovered(item);
+
+    if (isBlacklisted) {
+        emit _discoveryData->silentlyExcluded(path);
+    } else {
+        emit _discoveryData->itemDiscovered(item);
+    }
+
     return true;
 }
 
index a18fc601458a15a36a28c6675f6a6b6155dd59cb..ae886cae48938795d03b42735e6233a0142fb248 100644 (file)
@@ -148,7 +148,7 @@ private:
 
     // return true if the file is excluded.
     // path is the full relative path of the file. localName is the base name of the local entry.
-    bool handleExcluded(const QString &path, const Entries &entries, const std::map<QString, Entries> &allEntries, bool isHidden);
+    bool handleExcluded(const QString &path, const Entries &entries, const std::map<QString, Entries> &allEntries, bool isHidden, bool isBlacklisted);
 
     bool canRemoveCaseClashConflictedCopy(const QString &path, const std::map<QString, Entries> &allEntries);